<?php

namespace App\Modules\Admin\Services\Member;

use App\Modules\Admin\Entities\Member\UserCardModel;

use App\Modules\Admin\Services\BaseService;

class UsersCardService extends BaseService
{

    public function __construct(UserCardModel $model)
    {
        $this->model = $model;
        $this->with=['user_info','water_device_info','water_card'];
    }
    public function lists(array $params) : array
    {

        $params['where_callback'] = function($query) use ($params){
            $request = request();
            // 按照名称进行搜索
//            if (!empty($search = $request->input('search', ''))){
//                $query->where('nickname', 'LIKE', '%' . trim($search) . '%');
//            }
            if (!empty($search = $request->input('search', ''))){
                $query->where('card_code', 'LIKE', '%' . trim($search) . '%');
            }
//            if (!empty($search = $request->input('search', ''))){
//                $query->where('card_code', 'LIKE', '%' . trim($search) . '%');
//            }
        };
        return parent::lists($params); // TODO: Change the autogenerated stub

    }

}
